package com.mocha.bss.org.api.fallback;

import com.coffee.core.CoffeeResponse;
import com.coffee.core.CoffeeResponseEnum;
import com.mocha.bss.org.api.AdmdivFeignService;
import com.mocha.bss.org.bo.PathBO;
import com.mocha.bss.org.vo.AdmdivVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author songkui
 * @since 2025/03/24
 */
@Service
@Slf4j
public class AdmdivFeignFallbackFactory implements FallbackFactory<AdmdivFeignService> {
    @Override
    public AdmdivFeignService create(Throwable cause) {
        return new AdmdivFeignService() {
            @Override
            public CoffeeResponse<List<AdmdivVO>> listById(Long id) {
                log.error("Feign Throwable: {}", cause.getMessage());
                return CoffeeResponse.response(CoffeeResponseEnum.SysException);
            }

            @Override
            public CoffeeResponse<List<AdmdivVO>> listByParentId(Long id) {
                log.error("Feign Throwable: {}", cause.getMessage());
                return CoffeeResponse.response(CoffeeResponseEnum.SysException);
            }

            @Override
            public CoffeeResponse<List<AdmdivVO>> listInPath(PathBO bo) {
                log.error("Feign Throwable: {}", cause.getMessage());
                return CoffeeResponse.response(CoffeeResponseEnum.SysException);
            }

            @Override
            public CoffeeResponse<List<AdmdivVO>> filter(PathBO bo) {
                log.error("Feign Throwable: {}", cause.getMessage());
                return CoffeeResponse.response(CoffeeResponseEnum.SysException);
            }

            @Override
            public CoffeeResponse<String[]> paths(PathBO bo) {
                log.error("Feign Throwable: {}", cause.getMessage());
                return CoffeeResponse.response(CoffeeResponseEnum.SysException);
            }
        };
    }
}
